/*
 * trace_PathStackInfo.c
 *
 *  Created on: 2012/08/06
 *      Author: guanxiaoying
 */

#include "../table.h"
#include "../trace_cmd_table.h"
typedef struct _PATHSTACKINFO
{
	AST			astPath;
	AST			astPathNext;
	AST			astPathParam;
}PATHSTACKINFO, *PPATHSTACKINFO;

#define TableSize  (sizeof(PATHSTACKINFO ))
#define TableType  PPATHSTACKINFO
#define stTable stPathStackInfoManager.memoryBlocks
#define maxTable stPathStackInfoManager.maxRecordNum
#define  maxNumPerBlk  (stPathStackInfoManager.astMaxNum_Block)


static TABLEMANAGER stPathStackInfoManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stPathStackInfoManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stPathStackInfoManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stPathStackInfoManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stPathStackInfoManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}

static AST getCurrentObj( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPath;
}
static AST setCurrentObj( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPath=value;
}
static AST getNextObj( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathNext;
}
static AST setNextObj( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathNext=value;
}
static AST getParam( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathParam;
}
static AST setParam( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathParam=value;
}
//static AST getCmdStk( AST astIndex ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astCmdStk;
//}
//static AST setCmdStk( AST astIndex, AST value ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astCmdStk=value;
//}
//static AST getCmdLoop( AST astIndex ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astLoop;
//}
//static AST setCmdLoop( AST astIndex, AST value ){
//	TableType pTbl = core_getTable( astIndex );
//	if( pTbl == NULL )
//	{
//		return 0;
//	}
//	return pTbl->astLoop=value;
//}
const TRPATHSTACKINFOACCESS stTrPathStkAccess ={
		ClearTable,
		AllocTable,
		getMaxLineNum,
		{
				getCurrentObj,
				setCurrentObj
		},
		{
				getNextObj,
				setNextObj
		},
		{
				getParam,
				setParam
		}
};



